﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using JasLib.Extensions;
using Microsoft.Win32.SafeHandles;

namespace JasLib.Interop.Win32
{
    /// <summary>
    /// "msvcrt.dll" is automatically shipped with the OS, starting with Windows 2000.
    /// </summary>
    public static partial class MSVCRT
    {
        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "memcmp", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern int memcmp(UINT_PTR buf1, UINT_PTR buf2, UINT_PTR count);

        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "memcpy", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern UINT_PTR memcpy(UINT_PTR dest, UINT_PTR src, UINT_PTR count);

        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "memcpy_s", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern errno_t memcpy_s(
            [In] UINT_PTR dest,
            [In] UINT_PTR numberOfElements,
            [In] UINT_PTR src,
            [In] UINT_PTR count);

        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "memmove", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern UINT_PTR memmove(UINT_PTR dest, UINT_PTR src, UINT_PTR count);

        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "memset", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern UINT_PTR memset(UINT_PTR dest, int c, UINT_PTR count);

        [DllImport(Constants.ModuleNames.MSVCRT, EntryPoint = "wmemcpy_s", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
        public static extern errno_t wmemcpy_s(
            [In] UINT_PTR dest,
            [In] UINT_PTR numberOfElements,
            [In] UINT_PTR src,
            [In] UINT_PTR count);
    }
}
